import React, {Component} from 'react';
import {Link, Route} from "react-router-dom";

const Home = React.lazy(() => import('./Home'));
const About = React.lazy(() => import('./About'));

class LazyLoad extends Component {
    render() {
        return (
            <div>
                <Link to="/home">Home</Link>
                <Link to="/about">About</Link>
                <React.Suspense fallback={<h1>loading...</h1>}>
                    <Route path={"/home"} component={Home}/>
                    <Route path={"/about"} component={About}/>
                </React.Suspense>
            </div>
        );
    }
}

export default LazyLoad;